<style>
    .commit .popover {
        max-width: 400px !important;
    }

</style>
<div class="modal-header">
    <h3 class="modal-title">
        <b style="color: #286090">持续集成-构建</b>
    </h3>
</div>
<div class="modal-body">

    <form class="bs-example form-horizontal">

        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>

            <uib-tabset>
                <uib-tab index="0" heading="执行构建">

                    <div style="font-size:1em;">&nbsp;</div>

                    <div class="form-group">
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label"><span style="color: #ec2121;">*</span>任务名称
                            </label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="仓库地址" readonly
                                       ng-model="jobItem.jobName">
                            </div>
                        </div>

                        <div class="col-md-6">
                            <label class="col-lg-4 control-label"><span style="color: #ec2121;">*</span>服务器组
                            </label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="服务器组名称" readonly
                                       ng-model="appItem.serverGroupName">
                            </div>
                        </div>
                    </div>

                    <div class="form-group build-params">
                        <label class="col-lg-2 control-label">仓库地址</label>
                        <div class="col-lg-10">
                            <input type="text" class="form-control" placeholder="仓库地址" readonly
                                   ng-model="appItem.sshUrl">
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-6" ng-show="hostPatternList != null && hostPatternList.length != 0">
                            <label class="col-lg-4 control-label">
                                <!--HostPattern-->
                                <button ng-click="showHostPattern()"
                                        class="btn btn-xs"
                                        style="background-color: #2b669a; color: white;"
                                        uib-popover-html="'查看详情'"
                                        popover-trigger="'mouseenter'">
                                    <span class="glyphicon glyphicon-search"></span>主机组分组
                                </button>
                            </label>
                            <div class="col-lg-8">
                                <select class="form-control" ng-model="nowHostPattern.selected"
                                        ng-options="hp as hp.hostPattern for hp in hostPatternList" required>
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>

                        <div class="col-md-6">
                            <label class="col-lg-4 control-label">
                                <!--HostPattern-->
                                <button ng-click="showCommit()"
                                        class="btn btn-xs"
                                        style="background-color: #2b669a; color: white;"
                                        uib-popover-html="'查看变更记录'"
                                        popover-trigger="'mouseenter'">
                                    <span class="glyphicon glyphicon-search"></span>分支
                                </button>
                            </label>

                            <div class="col-lg-8">
                                <!--required-->
                                <select class="form-control" ng-model="jobItem.branch"
                                        ng-options="branch.name as branch.name for branch in jobItem.branchList">
                                    <option value="">--请选择--</option>
                                </select>
                            </div>
                        </div>
                    </div>

                    <div class="form-group" ng-show="isShowHostPattern">
                        <div class="col-md-12">
                            <label class="col-md-2 control-label">服务器列表</label>
                            <div class="col-md-10" style="box-shadow: 0 0 5px #ddd;padding: 10px">
                                <div class="col-md-6" ng-repeat="server in nowHostPattern.selected.servers">
                                    <b style="margin-left: 5px; color: #286090"
                                       uib-popover-html="server.deployVersionInfo"
                                       popover-trigger="'mouseenter'">
                                        {{server.serverName}}-{{server.serialNumber}}&nbsp;{{server.insideIp}}&nbsp;{{server.ciBuildDO.versionName}}</b>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-group commit" ng-show="commitList.length != 0">
                        <div class="col-md-12">
                            <label class="col-md-2 control-label">变更记录</label>
                            <div class="col-md-10" style="box-shadow: 0 0 5px #ddd;padding: 10px">
                                <div style="margin-top: 5px" class="col-md-12" ng-repeat="commit in commitList">

                                      <span style="background-color: #777777; color: white;"
                                            uib-popover-html="commit.id"
                                            popover-trigger="'mouseenter'"
                                            class="label">
                                                   <i class="fa fa-share-alt"></i>{{commit.message}}</span>

                                </div>
                            </div>
                        </div>
                    </div>


                    <div class="form-group" ng-show="false">
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label">任务模版
                            </label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="任务模版" readonly
                                       ng-model="jobItem.jobTemplate">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label">任务版本
                            </label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="版本编号" readonly
                                       ng-model="jobItem.jobVersion">
                            </div>
                        </div>
                    </div>

                    <div class="form-group" ng-show="false">
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label">全局模版
                            </label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="任务模版" readonly
                                       ng-model="jobItem.ciTemplateDO.name">
                            </div>
                        </div>
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label">模版版本
                            </label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="版本编号" readonly
                                       ng-model="jobItem.ciTemplateDO.version">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <div class="col-md-6">
                            <label class="col-lg-4 control-label"><span style="color: #ec2121;">*</span>版本名称
                            </label>
                            <div class="col-lg-8">
                                <input type="text" class="form-control" placeholder="默认值:release-构建编号"
                                       ng-model="jobItem.versionName">
                            </div>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">版本说明</label>
                        <div class="col-lg-10">
                            <textarea class="form-control" cols="3" placeholder="简短描述"
                                      ng-model="jobItem.versionDesc"></textarea>
                        </div>
                    </div>

                    <div class="form-group">
                        <div style="text-align:center;">
                            <div style="text-align:center;">

                                <button ng-click="buildJob()"
                                        class="btn btn-xs"
                                        style="margin-left: 5px; background-color: #20a03f; color: white;">
                                    <span class="icon icon-control-play"></span>执行
                                </button>
                            </div>
                        </div>
                    </div>
                </uib-tab>
                <uib-tab index="1" heading="构建参数" ng-show="jobItem.id != 0">

                    <div style="font-size:1em;">&nbsp;</div>

                    <div style="margin-top: 5px;">
                        <table class="table table-hover table-bordered table-striped"
                               ng-show="jobItem.paramList != null && jobItem.paramList.length != 0">
                            <thead>
                            <tr>
                                <!--class="col-md-10"-->
                                <td class="col-md-3">参数</td>
                                <td>值</td>
                            </tr>
                            </thead>
                            <tbody>
                            <tr ng-repeat="param in jobItem.paramList">
                                <td>
                                      <span style="background-color: #286090; color: white;"
                                            uib-popover-html="{{param.content}}"
                                            popover-trigger="'mouseenter'"
                                            class="label">
                                                   <i ng-show="param.paramName =='branch'" class="fa fa-code-fork"></i>
                                                   <i ng-show="param.paramName =='sshUrl'" class="fa fa-git"></i>{{param.paramName}}</span>
                                </td>
                                <td>
                                     <span class="label" style="background-color: #20a03f; color: white;">
                                                {{param.paramValue}}</span>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>

                </uib-tab>
                <uib-tab index="2" heading="BuildHistory">

                    <div style="font-size:1em;">&nbsp;</div>
                    <div class="panel-body">
                        <div>
                            <table class="table table-hover table-bordered table-striped">
                                <thead>
                                <tr>
                                    <td class="col-md-1">编号</td>
                                    <td class="col-md-10">任务详情</td>
                                    <td class="col-md-1">操作</td>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="item in pageData">
                                    <td>
                                        <b style="color: #c9302c" ng-if="item.buildNumber ==-1">队列</b>
                                        <b style="color: #286090" ng-if="item.buildNumber > 0">{{item.buildNumber}}</b>
                                    </td>
                                    <td>
                                        <div ng-show="item.badgeIcon != ''"><img src="{{item.badgeIcon}}"></div>
                                        <b style="color: #286090">{{item.displayName}}</b>
                                        <span class="pull pull-right">
                                            {{(item.gmtModify == null || item.gmtModify == '') ? item.gmtCreate :
                                            item.gmtModify}}
                                        </span>
                                        <div class="col-md-12" style="margin-top:5px;"
                                             ng-repeat="param in item.jobParams.params">
                                               <span style="background-color: #286090; color: white;"
                                                     uib-popover-html="'参数名称'"
                                                     popover-trigger="'mouseenter'"
                                                     class="label">
                                                   <i ng-show="param.name =='branch'" class="fa fa-code-fork"></i>
                                                   <i ng-show="param.name =='sshUrl'" class="fa fa-git"></i>{{param.name}}</span>
                                            <b style="color: #20a03f;">{{param.value}}</b>
                                        </div>
                                        <!--margin: 0 auto  ;  height: 100px; margin-top:5px;-->
                                        <div class="col-md-12" style="margin-top:5px;"
                                             ng-repeat="commit in item.commitList">
                                               <span style="background-color: #777777; color: white;"
                                                     uib-popover-html="'COMMIT'"
                                                     popover-trigger="'mouseenter'"
                                                     class="label">
                                                  {{commit.commit}}</span>
                                            <span style="background-color: #8278c2; color: white;" class="label">{{commit.message}}</span>
                                        </div>
                                        <div class="col-md-12" style="margin-top:5px;"
                                             ng-repeat="notify in item.notifyList">
                                            <span style="background-color: #00b3ee; color: white;"
                                                  uib-popover-html="'阶段'"
                                                  popover-trigger="'mouseenter'"
                                                  class="col-md-2 label">
                                                   <i class="fa fa-codepen"></i>{{notify.buildPhase}}</span>
                                            <span style="background-color: #2a2a2b; color: white;"
                                                  uib-popover-html="'时间'"
                                                  popover-trigger="'mouseenter'"
                                                  class="col-md-4 label">
                                                   <i class="glyphicon glyphicon-time"></i>{{notify.gmtCreate}}</span>
                                            <span style="background-color: #20a03f; color: white;"
                                                  ng-if="notify.buildStatus =='SUCCESS'"
                                                  uib-popover-html="'状态'"
                                                  popover-trigger="'mouseenter'"
                                                  class="col-md-4 label">
                                                   <i class="glyphicon glyphicon-ok"></i>{{notify.buildStatus}}</span>
                                            <span style="background-color: red; color: white;"
                                                  ng-if="notify.buildStatus != '' && notify.buildStatus !='SUCCESS'"
                                                  uib-popover-html="'状态'"
                                                  popover-trigger="'mouseenter'"
                                                  class="col-md-4 label">
                                                   <i class="glyphicon glyphicon-remove"></i>{{notify.buildStatus}}</span>
                                            <span style="background-color: #737373; color: white;"
                                                  ng-show="notify.dingtalk == true"
                                                  class="label pull-right">
                                                   <i class="fa fa-bell"></i>Dingtalk消息</span>
                                        </div>

                                        <div class="col-md-12" style="margin-top:5px;"
                                             ng-repeat="artifact in item.artifactList">
                                               <span style="background-color: #c9302c; color: white;"
                                                     ng-show="artifact.ossPath != ''"
                                                     uib-popover-html="'OSS://opscloud'"
                                                     popover-trigger="'mouseenter'"
                                                     class="label">
                                                   <i class="fa fa-codepen"></i>OSS</span>

                                            <span style="background-color: #ff5f87; color: white;"
                                                  ng-show="artifact.ossPath != ''"
                                                  uib-popover-html="'构件路径'"
                                                  popover-trigger="'mouseenter'"
                                                  class="label">{{artifact.ossPath}}</span>

                                            <span style="background-color: #737373; color: white;"
                                                  ng-show="artifact.ossPath != ''"
                                                  class="label pull-right">{{artifact.size}}</span>

                                            <span style="background-color: #ff8700; color: white;"
                                                  ng-show="artifact.ossPath == ''"
                                                  uib-popover-html="'构件'"
                                                  popover-trigger="'mouseenter'"
                                                  class="label">
                                                   <i class="fa fa-dropbox"></i>{{artifact.artifactName}}</span>
                                        </div>


                                    </td>
                                    <td>
                                        <button ng-click="rebuildJob(item.id)"
                                                class="btn btn-xs"
                                                ng-disabled="butSaveDisabled"
                                                style="background-color: #ff8700; color: white;">
                                            <i class="fa fa-spin fa-spinner" ng-show="butBuildSpinDisabled"></i>
                                            <i class="icon icon-control-play" ng-show="!butBuildSpinDisabled"></i>执行
                                        </button>
                                        <!--margin-left: 5px;-->
                                        </br>
                                        <a class="btn btn-xs"
                                           style="margin-top:5px; background-color: #737373; color: white;"
                                           href="{{item.console}}"
                                           target="_blank"><i class="fa fa-terminal"></i>日志</a>
                                    </td>
                                </tr>
                                </tbody>
                                <tfoot>
                                <tr>
                                    <td colspan="4">
                                        <ul style="margin: 0px; float: right;" uib-pagination total-items="totalItems"
                                            ng-model="currentPage" items-per-page="pageLength" max-size="10"
                                            ng-change="pageChanged(currentPage)" previous-text="&lsaquo;"
                                            next-text="&rsaquo;"></ul>
                                    </td>
                                </tr>
                                </tfoot>
                            </table>
                        </div>
                    </div>
                </uib-tab>
            </uib-tabset>
        </div>

    </form>

    <div ng-if="alert.type != ''">
        <div uib-alert ng-class="'alert-' + alert.type" close="closeAlert()">{{alert.msg}}</div>
    </div>
</div>